import axios from 'axios'
// import * as api from '../../utils/api'
const state = {
    floorId: '',
    // 楼栋总平图
    floorBuildingDatas: [],
    // 交房
    floorDataData: [],
    // 房源
    HousingInformation: [],
    // 户型
    HouseType: [],
    // 价格
    FloorBuildingData: [],
    // 开盘
    QueryOpeningData: [],
    // 预售
    queryPresaleLicenseData: [],
    // 相册
    albumData: [],
    // 下拉菜单
    dropDownMenu: [],
}
// 放异步操作
const actions = {
    // 查询楼栋总平图信息接口
    queryBuilding(obj, row) {
        // 楼栋id
        let zero = row[0]
        // state值
        let one = row[1]
        // 业态id
        let two = row[2]
        if (parseInt(one) != '') {
            // console.log(123);
            // 查询交房信息接口
            axios({
                url: '/api/rema/queryHandover',
                method: 'get',
                params: {
                    currentPage: '',
                    pageSize: 100,
                    property_type_id: two,
                    real_estate_id: zero
                }
            }).then(data => {
                // console.log(data);
                obj.commit('floorDatas', data)
            }).catch(err => {
                // console.log(err);
            })
        }
        // 楼栋总平图
        if (parseInt(one) != '') {
            // console.log(222);
            axios({
                url: '/api/rema/queryBuilding',
                method: "get",
                params: {
                    currentPage: "",
                    pageSize: 100,
                    real_estate_id: zero,
                },
            })
                .then((data) => {
                    console.log(data);
                    obj.commit('floorBuildingDatas', data)
                })
                .catch((err) => {
                    // console.log(err);
                });
        }
        // 查询户型接口
        if (parseInt(one) != '') {
            axios({
                url: '/api/rema/queryUnitTypea',
                method: 'get',
                params: {
                    real_estate_id: zero
                }
            }).then(data => {
                obj.commit('HouseTypeData', data)
            }).catch(err => {
                // console.log(err);
            })
        }
        // 查询价格接口
        if (parseInt(one) != '') {
            axios({
                url: '/api/rema/queryPrice',
                method: 'get',
                params: {
                    currentPage: '',
                    pageSize: 100,
                    property_type_id: 1,
                    real_estate_id: 1
                }
            }).then(data => {
                obj.commit('FloorBuildingData', data)
                // console.log(data);
            })
        }
        // 查询开盘接口
        if (parseInt(one) != '') {
            axios({
                url: '/api/rema/queryOpening',
                method: 'get',
                params: {
                    currentPage: '',
                    pageSize: 100,
                    property_type_id: two,
                    real_estate_id: zero
                }
            }).then(data => {
                obj.commit('QueryOpeningData', data)
                // console.log(data);
            }).catch(err => {
                // console.log(err);
            })
        }
        // 查询预售接口
        if (parseInt(one) != '') {
            axios({
                url: '/api/rema/queryPresaleLicense',
                method: 'get',
                params: {
                    currentPage: '',
                    pageSize: 100,
                    property_type_id: two,
                    real_estate_id: zero
                }
            }).then(data => {
                obj.commit('queryPresaleLicenseFun', data)
                // console.log(data);
            })
        }
        // 查询相册接口
        if (parseInt(one) != '') {
            axios({
                url: '/api/rema/queryPhotoAlbum',
                method: 'get',
                params: {
                    album_id: 1,
                    currentPage: 1,
                    pageSize: 60,
                    property_type_id: two,
                    real_estate_id: zero
                }
            }).then(data => {
                obj.commit('albumDatafun', data)
                // console.log(data);
            }).catch(err=>{
                // console.log(err);
            })
        }
    },

}
// 放同步操作
const mutations = {
    floorChangeId(state, row) {
        // console.log(123);
        state.row = row
    },
    // 楼栋总平图
    floorBuildingDatas(state, data) {
        state.floorBuildingDatas = data.data.data.dataList
    },
    // 交房数据
    floorDatas(state, data) {
        // console.log(data);
        state.floorDataData = data.data.data.dataList
        // console.log(state.floorDataData);
    },
    // 户型
    HouseTypeData(state, data) {
        state.HouseType = data.data.data
        // console.log(state.HouseType);
    },
    // 价格
    FloorBuildingData(state, data) {
        // console.log(data);
        state.FloorBuildingData = data.data.data.dataList
        // console.log(state.FloorBuildingData);
    },
    // 开盘
    QueryOpeningData(state, data) {
        state.QueryOpeningData = data.data.data.dataList
        // console.log(state.QueryOpeningData);
    },
    // 预售
    queryPresaleLicenseFun(state, data) {
        state.queryPresaleLicenseData = data.data.data.dataList;
        // console.log(state.queryPresaleLicenseData);
    },
    // 相册
    albumDatafun(state, data) {
        state.albumData = data.data.data.dataList
        // console.log(state.albumData);
    },
    // 下拉菜单
    dropDownMenuFun(state, data) {
        state.dropDownMenu = data
    }
}

export default {
    state,
    actions,
    mutations
}
